package org.cmcc.xdr.parse;

import java.io.File;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.cmcc.xdr.bo.XdrParseInfo;
import com.cmcc.xdr.entity.AuthenEntity;
import com.cmcc.xdr.entity.BaseEntity;
import com.cmcc.xdr.entity.BiccEntity;
import com.cmcc.xdr.entity.ComposedEntity;
import com.cmcc.xdr.entity.PccEntity;
import com.cmcc.xdr.entity.SipCallEntity;
import com.cmcc.xdr.entity.SipRegEntity;
import com.cmcc.xdr.entity.SipSrvccEntity;
import com.cmcc.xdr.entity.SrvccEntity;
import com.cmcc.xdr.entity.StatXdrexclogEntity;
import com.cmcc.xdr.util.TBCDUtil;
import com.csvreader.CsvReader;

public class XdrCsvParseUtil {
	private static Logger log = LogManager.getLogger(XdrCsvParseUtil.class);
	
	public static List<BaseEntity> parse(XdrParseInfo xdrParseInfo)
	{
		List<BaseEntity> entities = new ArrayList<BaseEntity>();
		String upAllChkName = xdrParseInfo.getUpAllChkName();
		List<String> listName = xdrParseInfo.getListName();
		String csvFilePath = xdrParseInfo.getCsvFilePath();
		String volte_exists_colName = xdrParseInfo.getVolte_exists_colName();
		
		String[] xdrComposedCols = xdrParseInfo.getXdrComposedCols();
		String[] xdrSipCols = xdrParseInfo.getXdrSipCols();
		String[] xdrSvCols = xdrParseInfo.getXdrSvCols();
		String[] xdrAuthenCols = xdrParseInfo.getXdrAuthenCols();
		String[] xdrPccCols = xdrParseInfo.getXdrPccCols();
		
		
    	if(upAllChkName.indexOf("_LTESIG_") != -1 || upAllChkName.indexOf("_VOLTESIG_") != -1 || upAllChkName.indexOf("_USER_") != -1  || upAllChkName.indexOf("_UEMR_") != -1 ){
    		/**
    		 * ====================合成接口文件处理开始 =================
    		 */
    		for (String csvName : listName) {//读取与chk验证文件相同名称的csv文件（之前放入list中的名称）
        		int size = 0;
        		int errorsize = 0;
        		int notsize = 0;
                CsvReader r = null;
        		try {
					r = new CsvReader(csvFilePath + File.separator + csvName, '|', Charset.forName("UTF-8"));
                    while (r.readRecord()) {
                    	String interfaceStr = "";
                    	String tablename = "";
                		try {
	                		size ++ ;
	                		String[] fieldList = r.getValues();
	                		if(size == 1 && ("1").equals(volte_exists_colName) ){//文件包含列名，排除第一行
	                			xdrComposedCols = fieldList;
	                		}else{
	                			//第一条不用判断替换
	                			for(int i=1;i<fieldList.length;i++){
	                				if(fieldList[i].equals("255") || fieldList[i].equals("65535") || fieldList[i].equals("4294967295")){
                						fieldList[i] = "";
	                				}
	                			}
                    			tablename = "xdr_composed";
                    		    //按每条合成接口记录的多个单接口部分拆分为多条数据入库
                    			String[] resList=new String[fieldList.length];
                    			for(int i=0;i<19;i++){  //通用部分
                    				resList[i]=fieldList[i];
                    			}
                    			if(fieldList.length>18){  //单接口部分
                    				int m=19;
                    				int n=19;
                    				while(m<fieldList.length){
                    					for(int i=0;i<10;i++){
                    						resList[n+i]=fieldList[m];
                    						m++;
                    					}
                    					ComposedEntity composed = singleComposed(xdrComposedCols,resList);
                    					entities.add(composed);
                    				}
                    			}
	                		}
						} catch (Exception e) {
							errorsize ++;
							StatXdrexclogEntity sxc = new StatXdrexclogEntity();
							sxc.setTablename(tablename);
							sxc.setExccount(1);
							sxc.setInterFace(interfaceStr);
							sxc.setExcreason(csvName+"：第 "+size+"行,解析或入库异常");
							sxc.setInserttime(new Date());
							entities.add(sxc);
							log.error(csvName+" ：第 "+size+" 行,合成接口数据解析或入库出现异常则直接丢弃：",e);
							continue;
						}
                    }
    			} catch (Exception e) {
					errorsize ++;
					e.printStackTrace();
					log.error(csvName + "合成接口文件解析异常：",e);
    			} finally {
					if (r != null) {
						r.close();
					}
    			}
	      		log.info(csvName+"合成接口处理完毕，共处理：所有:"+size+",错误："+errorsize+"，未找到："+notsize);
			}
    		/**
    		 * ====================合成接口文件处理结束 =================
    		 */
    	}
    	else
    	{
    		/**
    		 * ====================单接口文件处理开始 =================
    		 */
    		for (String csvName : listName) {//读取与chk验证文件相同名称的csv文件（之前放入list中的名称）
        		int size = 0;
        		int errorsize = 0;
        		int notsize = 0;
        		CsvReader r = null;
        		try {
					r = new CsvReader(csvFilePath + File.separator + csvName, '|', Charset.forName("UTF-8"));
                    while (r.readRecord()) {
                    	String interfaceStr = "";
                    	String tablename = "";
                		try {
	                		size ++ ;
                			String[] fieldList = r.getValues();
                			if((size == 1 && ("1").equals(volte_exists_colName)) ){//文件包含列名，排除第一行
                				xdrSipCols = fieldList;
                				xdrSvCols = fieldList;	
                				xdrAuthenCols = fieldList;
                				xdrPccCols = fieldList;
                			}else{
	                			//第一条不用判断替换
	                			for(int i=1;i<fieldList.length;i++){
	                				if(fieldList[i].equals("255") || fieldList[i].equals("65535") || fieldList[i].equals("4294967295")){
                						fieldList[i] = "";
	                				}
	                			}
	                			//获取interface字段值
	                			String interfaceValue = "";
	                			String procedureType = "";
	                			for(int j=0;j<xdrSipCols.length;j++){
	                				String name=xdrSipCols[j].toUpperCase();
	                				if(name.contains("INTERFACE")){
	                					interfaceValue = fieldList[j];
	                				}else if(name.contains("PROCEDURE") && name.contains("TYPE")){
	                					procedureType = fieldList[j];
	                				}
	                			}
	                    		interfaceStr = interfaceValue;
	                    		if("13".equals(interfaceValue) || "14".equals(interfaceValue) || "15".equals(interfaceValue) || "16".equals(interfaceValue) || "17".equals(interfaceValue) || "18".equals(interfaceValue) ){
	                    			//Mw/Mg/Mi/Mj/ISC/Gm/I2/ ATCF-SCC AS接口XDR数据结构
	                    			if("1".equals(procedureType) || "2".equals(procedureType) || "3".equals(procedureType) || "4".equals(procedureType)){
	                    				//1：Register； 2：Deregister； 3：3rd-Register； 4：3rd-Deregister；
	                    				tablename = "xdr_sipreg";
	                    				SipRegEntity sipreg = singleSipRegMsg(xdrSipCols,fieldList);
	                    				entities.add(sipreg);
	                    			}else if("5".equals(procedureType)){
	                    				//5：Calling；
	                    				tablename = "xdr_sipcall";
	                    				SipCallEntity sipcall = singleSipCallMsg(xdrSipCols,fieldList);
	                    				entities.add(sipcall);
	                    			}else if("6".equals(procedureType)){
	                    				//6：INVITE from eMSC
	                    				tablename = "xdr_sipsrvcc";
	                    				SipSrvccEntity sipSrvcc = singleSipSrvccMsg(xdrSipCols,fieldList);
	                    				entities.add(sipSrvcc);
	                    			}else{
	                    				notsize ++;
	                    				log.debug("未找到的类型，procedureType="+procedureType);
	                    			}
	                    		}else if("19".equals(interfaceValue)){
	                    			//Sv接口XDR数据结构
	                    			tablename = "xdr_srvcc";
	                    			SrvccEntity sv = singleSrvcc(xdrSvCols,fieldList);
	                    			entities.add(sv);
	                    		}else if("20".equals(interfaceValue) || "21".equals(interfaceValue) || "22".equals(interfaceValue) || "23".equals(interfaceValue) || "24".equals(interfaceValue) ){
	                    			//Cx/Dx/Sh/Dh/Zh接口XDR数据结构
	                    			tablename = "xdr_authen";
	                    			AuthenEntity authen = singleSigAuthen(xdrAuthenCols,fieldList);
	                    			entities.add(authen);
	                    		}else if("25".equals(interfaceValue) || "26".equals(interfaceValue)){
	                    			//Gx/Rx接口XDR数据结构
	                    			tablename = "xdr_pcc";
	                    			PccEntity pcc = singleSigPccMsg(xdrPccCols,fieldList);
	                    			entities.add(pcc);
	                    		}else if("28".equals(interfaceValue)){
	                    			//Nc接口XDR数据结构
	                    			tablename = "xdr_bicc";
	                    			BiccEntity bicc = singleSigBiccMsg(fieldList);
	                    			entities.add(bicc);
	                    		}else{
                    				notsize ++;
                    				StatXdrexclogEntity sxc = new StatXdrexclogEntity();
									sxc.setTablename(tablename);
									sxc.setExccount(1);
									sxc.setInterFace(interfaceStr);
									sxc.setExcreason(csvName+"：第 "+size+"行，没找到的接口类型");
									sxc.setInserttime(new Date());
									entities.add(sxc);
	                    			log.error(csvName+" ：第 "+size+" 行,======没有找到的接口类型=======");
	                    		}
                		    }
						} catch (Exception e) {
							errorsize ++;
							StatXdrexclogEntity sxc = new StatXdrexclogEntity();
							sxc.setTablename(tablename);
							sxc.setExccount(1);
							sxc.setInterFace(interfaceStr);
							sxc.setExcreason(csvName+"：第 "+size+"行,解析或入库异常");
							sxc.setInserttime(new Date());
							entities.add(sxc);
							log.error(csvName+" ：第 "+size+" 行,单接口数据解析或入库出现异常则直接丢弃：",e);
							continue;
						}
                    }
				} catch (Exception e) {
					errorsize ++;
					e.printStackTrace();
					log.error(csvName + "单接口文件解析异常：",e);
				} finally {
					if(r != null){
						r.close();
					}
				}
	      		log.info(csvName+"单接口文件处理完毕，共处理：所有:"+size+",错误："+errorsize+"，未找到："+notsize);
			}
    		/**
    		 * ====================单接口文件处理结束 =================
    		 */
    	}
    	return entities;
	}

	public static ComposedEntity singleComposed(String[] cols,String[] fieldList) throws ParseException{
		SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
		ComposedEntity composed = new ComposedEntity();
		//区分一条合成接口记录包含多个相同字段的单接口部分
		//公共通用部分
		for(int i=0;i<19;i++){      //按列名匹配值防止字段顺序不一致
			String param=cols[i].toUpperCase();
			String value=fieldList[i];
			if(param.contains("XDR") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
				composed.setXdrType(Integer.parseInt(value));
			}else if(param.contains("XDR") && param.contains("ID")){
				composed.setXdrId(value);
			}else if(param.contains("PROCEDURE") && param.contains("START") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
				composed.setProcedureStartTime(new Date(format.parse(value).getTime()));
			}else if(param.contains("PROCEDURE") && param.contains("END") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
				composed.setProcedureEndTime(new Date(format.parse(value).getTime()));
			}else if(param.contains("PROCEDURE") && param.contains("STATUS") && TBCDUtil.checkNotNull(value)){
				composed.setProcedureStatus(Integer.parseInt(value));
			}
		}
		//单接口部分字段
		for(int i=19;i<fieldList.length;i++){
			String param=cols[i].toUpperCase();
			String value=fieldList[i];
			if(param.contains("INTERFACE") && TBCDUtil.checkNotNull(value)){
				composed.setInterface(Integer.parseInt(value));
			}else if(param.contains("XDR") && param.contains("ID") && TBCDUtil.checkNotNull(value)){
				composed.setSingleXdrId(value);
			}else if(param.contains("PROCEDURE") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
				composed.setSingleProcedureType(Integer.parseInt(value));
			}
		}
	//	composed.setCallingId(0);
	//	composed.setCalledId(0);
		composed.setInsertDate(format.format(new Date()));

		return composed;
	}
	
    public static SipRegEntity singleSipRegMsg(String[] cols,String[] fieldList) throws ParseException{
    	SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
    	SipRegEntity sipreg = new SipRegEntity();
    	for(int i=0;i<cols.length;i++){
    		String param=cols[i].toUpperCase();
    		String value=fieldList[i];
    		if(param.contains("LENGTH") && TBCDUtil.checkNotNull(value)){
    			sipreg.setLength(Integer.parseInt(value));
    		}else if(param.contains("LOCAL") && param.contains("PROVINCE")){
    			sipreg.setLocalProvince(value);
    		}else if(param.contains("LOCAL") && param.contains("CITY")){
    			sipreg.setLocalCity(value);
    		}else if(param.contains("OWNER") && param.contains("PROVINCE")){
    			sipreg.setOwnerProvince(value);//OWNER_PROVINCE3
    		}else if(param.contains("OWNER") && param.contains("CITY")){
    			sipreg.setOwnerCity(value);//OWNER_CITY4
    		}else if(param.contains("ROAMING") && param.contains("TYPE")){
    			sipreg.setRoamingType(value);//ROAMING_TYPE5
    		}else if(param.contains("INTERFACE") && TBCDUtil.checkNotNull(value)){
    			sipreg.setInterFace(Integer.parseInt(value));
    		}else if(param.contains("XDR") && param.contains("ID")){
    			sipreg.setXdrId(value);
    		}else if(param.contains("RAT")  && !param.contains("CALL") && TBCDUtil.checkNotNull(value)){
    			sipreg.setRat(Integer.parseInt(value));
    		}else if(param.contains("IMSI") && !param.contains("SOURCE") && !param.contains("DEST")){
    			sipreg.setImsi(value);
    		}else if(param.contains("IMEI") && !param.contains("SOURCE") && !param.contains("DEST")){
    			sipreg.setImei(value);
    		}else if(param.contains("MSISDN") && !param.contains("C")){
    			sipreg.setMsisdn(value);
    		}else if(param.contains("PROCEDURE") && param.contains("START") && param.contains("TIME")){
    			sipreg.setProcedureStartTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("END") && param.contains("TIME")){
    			sipreg.setProcedureEndTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipreg.setProcedureType(Integer.parseInt(value));
    		}else if(param.contains("PROCEDURE") && param.contains("STATUS") && TBCDUtil.checkNotNull(value)){
    			sipreg.setProcedureStatus(Integer.parseInt(value));
    		}else if(param.contains("REQUEST") && param.contains("URI")){
    			sipreg.setRequestUri(value);
    		}else if(param.contains("USER") && param.contains("IP")){
    			sipreg.setUserIp(value);
    		}else if(param.contains("CALL") && param.contains("ID") && !param.contains("VIDEO")){
    			sipreg.setCallid(value);
    		}else if(param.contains("IC") && param.contains("ID")){
    			sipreg.setIcid(value);
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("IP")){
    			sipreg.setSourceNeIp(value);
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			sipreg.setSourceNePort(Integer.parseInt(value));
    		}else if(param.contains("DEST") && param.contains("NE") && param.contains("IP")){
    			sipreg.setDestNeIp(value);
    		}else if(param.contains("DEST") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			sipreg.setDestNePort(Integer.parseInt(value));
    		}else if(param.contains("SOURCE") && param.contains("ACCESS") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipreg.setSourceAccessType(Integer.parseInt(value));
    		}else if(param.contains("SOURCE") && param.contains("ECI")){
    			sipreg.setSourceEci(value);
    		}else if(param.contains("SOURCE") && param.contains("TAC")){
    			sipreg.setSourceTac(value);
    		}else if(param.contains("AUTH") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipreg.setAuthType(Integer.parseInt(value));
    		}else if(param.contains("EXPIRES") && param.contains("TIME") && param.contains("REQ") && TBCDUtil.checkNotNull(value)){
    			sipreg.setExpiresTimeReq(Integer.parseInt(value));
    		}else if(param.contains("EXPIRES") && param.contains("TIME") && param.contains("RSP") && TBCDUtil.checkNotNull(value)){
    			sipreg.setExpiresTimeRsp(Integer.parseInt(value));
    		}else if(param.contains("RESPONSE") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			sipreg.setResponseCode(Integer.parseInt(value));
    		}else if(param.contains("FINISH") && param.contains("WARNING") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			sipreg.setFinishWarningCode(Integer.parseInt(value));
    		}else if(param.contains("FINISH") && param.contains("REASON") && param.contains("PROTOCOL") && TBCDUtil.checkNotNull(value)){
    			sipreg.setFinishReasonProtocol(Integer.parseInt(value));
    		}else if(param.contains("FINISH") && param.contains("REASON") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			sipreg.setFinishReasonCause(Integer.parseInt(value));
    		//v240 start
    		}else if(param.contains("CANCEL") && param.contains("REASON") && param.contains("PROTOCOL") && TBCDUtil.checkNotNull(value)){
    			sipreg.setCancelReasonProtocal(Integer.parseInt(value));
    		}else if(param.contains("CANCEL") && param.contains("REASON") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			sipreg.setCancelReasonCause(Integer.parseInt(value));
    		}else if(param.contains("183") && param.contains("REASON") && param.contains("PROTOCOL") && TBCDUtil.checkNotNull(value)){
    			sipreg.setReasonProtocolof183(Integer.parseInt(value));
    		}else if(param.contains("183") && param.contains("REASON") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			sipreg.setReasonCauseof183(Integer.parseInt(value));
    		//v240 end
    		}else if(param.contains("AUTH") && param.contains("REQ") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipreg.setAuthReqTime(Integer.parseInt(value));
    		}else if(param.contains("AUTH") && param.contains("RSP") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipreg.setAuthRspTime(Integer.parseInt(value));
    		}else if(param.contains("STN") && param.contains("SR")){
    			sipreg.setStnSr(value);
    		}else if(param.contains("ATCF") && param.contains("MGMT")){
    			sipreg.setAtcfMgmt(value);
    		//v240 start
    		}else if(param.contains("RETRY") && param.contains("AFTER") && TBCDUtil.checkNotNull(value)){
    			sipreg.setRetryAfter(Integer.parseInt(value));
    		}else if(param.contains("USER") && param.contains("AGENT")){
    			sipreg.setUserAgent(value);
    		//v240 end
    		}
    	}
		sipreg.setInsertDate(format.format(new Date()));
    	return sipreg;
    }
    
    public static SipCallEntity singleSipCallMsg(String[] cols,String[] fieldList) throws ParseException{
    	SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
    	SipCallEntity sipcall = new SipCallEntity();
    	for(int i=0;i<cols.length;i++){
    		String param=cols[i].toUpperCase();
    		String value=fieldList[i];
    		if(param.contains("LENGTH") && TBCDUtil.checkNotNull(value)){
    			sipcall.setLength(Integer.parseInt(value));
    		}else if(param.contains("LOCAL") && param.contains("PROVINCE")){
    			sipcall.setLocalProvince(value);
    		}else if(param.contains("LOCAL") && param.contains("CITY")){
    			sipcall.setLocalCity(value);
    		}else if(param.contains("OWNER") && param.contains("PROVINCE")){
    			sipcall.setOwnerProvince(value);//OWNER_PROVINCE3
    		}else if(param.contains("OWNER") && param.contains("CITY")){
    			sipcall.setOwnerCity(value);//OWNER_CITY4
    		}else if(param.contains("ROAMING") && param.contains("TYPE")){
    			sipcall.setRoamingType(value);//ROAMING_TYPE5
    		}else if(param.contains("INTERFACE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setInterFace(Integer.parseInt(value));
    		}else if(param.contains("XDR") && param.contains("ID")){
    			sipcall.setXdrId(value);
    		}else if(param.contains("RAT")  && !param.contains("CALL") && TBCDUtil.checkNotNull(value)){
    			sipcall.setRat(Integer.parseInt(value));
    		}else if(param.contains("IMSI") && !param.contains("SOURCE") && !param.contains("DEST")){
    			sipcall.setImsi(value);
    		}else if(param.contains("IMEI") && !param.contains("SOURCE") && !param.contains("DEST")){
    			sipcall.setImei(value);
    		}else if(param.contains("MSISDN") && !param.contains("C")){
    			sipcall.setMsisdn(value);
    		}else if(param.contains("PROCEDURE") && param.contains("START") && param.contains("TIME")){
    			sipcall.setProcedureStartTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("END") && param.contains("TIME")){
    			sipcall.setProcedureEndTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setProcedureType(Integer.parseInt(value));
    		}else if(param.contains("SERVICE") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setServiceType(Integer.parseInt(value));
    		}else if(param.contains("PROCEDURE") && param.contains("STATUS") && TBCDUtil.checkNotNull(value)){
    			sipcall.setProcedureStatus(Integer.parseInt(value));
    		}else if(param.contains("CALLING") && param.contains("NUMBER")){
    			sipcall.setCallingNumber(value);
    		}else if(param.contains("CALLED") && param.contains("NUMBER")){
    			sipcall.setCalledNumber(value);
    		}else if(param.contains("CALLING") && param.contains("PARTY") && param.contains("URI")){
    			sipcall.setCallingPartyUri(value);
    		}else if(param.contains("REQUEST") && param.contains("URI")){
    			sipcall.setRequestUri(value);
    		}else if(param.contains("USER") && param.contains("IP")){
    			sipcall.setUserIp(value);
    		}else if(param.contains("IC") && param.contains("ID")){
    			sipcall.setIcId(value);
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("IP")){
    			sipcall.setSourceNeIp(value);
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			sipcall.setSourceNePort(Integer.parseInt(value));
    		}else if(param.contains("DEST") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			sipcall.setDestNePort(Integer.parseInt(value));
    		}else if(param.contains("DEST") && param.contains("NE") && param.contains("IP")){
    			sipcall.setDestNeIp(value);
    		}else if(param.contains("CALL") && param.contains("SIDE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setCallSide(Integer.parseInt(value));
    		}else if(param.contains("SOURCE") && param.contains("ACCESS")&& param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setSourceAccessType(Integer.parseInt(value));
    		}else if(param.contains("SOURCE") && param.contains("ECI")){
    			sipcall.setSourceEci(value);
    		}else if(param.contains("SOURCE") && param.contains("TAC")){
    			sipcall.setSourceTac(value);
    		}else if(param.contains("SOURCE") && param.contains("IMSI")){
    			sipcall.setSourceImsi(value);
    		}else if(param.contains("SOURCE") && param.contains("IMEI")){
    			sipcall.setSourceImei(value);
    		//v240 start
    		}else if(param.contains("SOURCE") && param.contains("SBC") && param.contains("DOMAIN")){
    			sipcall.setSourceSbcDomain(value);
    		//v240 end
    		}else if(param.contains("DEST") && param.contains("ACCESS")&& param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setDestAccessType(Integer.parseInt(value));
    		}else if(param.contains("DEST") && param.contains("ECI")){
    			sipcall.setDestEci(value);
    		}else if(param.contains("DEST") && param.contains("TAC")){
    			sipcall.setDestTac(value);
    		}else if(param.contains("DEST") && param.contains("IMSI")){
    			sipcall.setDestImsi(value);
    		}else if(param.contains("DEST") && param.contains("IMEI")){
    			sipcall.setDestImei(value);
    			//v240 start
    		}else if(param.contains("DEST") && param.contains("SBC") && param.contains("DOMAIN")){
    			sipcall.setDestSbcDomain(value);
    		//v240 end
    		}else if(param.contains("CALLING") && param.contains("SDP") && param.contains("IP")){
    			sipcall.setCallingSdpIpAddr(value);
    		}else if(param.contains("CALLING") && param.contains("AUDIO")&& param.contains("SDP") && TBCDUtil.checkNotNull(value)){
    			sipcall.setCallingAudioSdpPort(Integer.parseInt(value));
    		}else if(param.contains("CALLING") && param.contains("VIDEO")&& param.contains("SDP") && TBCDUtil.checkNotNull(value)){
    			sipcall.setCallingVideoSdpPort(Integer.parseInt(value));
    		}else if(param.contains("CALLED") && param.contains("SDP") && param.contains("IP")){
    			sipcall.setCalledSdpIpAddr(value);
    		}else if(param.contains("CALLED") && param.contains("AUDIO")&& param.contains("SDP") && TBCDUtil.checkNotNull(value)){
    			sipcall.setCalledAudioSdpPort(Integer.parseInt(value));
    		}else if(param.contains("CALLED") && param.contains("VIDEO")&& param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			sipcall.setCalledVideoPort(Integer.parseInt(value));
    		}else if(param.contains("CALL") && param.contains("ID")){
    			sipcall.setCallId(value);
    		}else if(param.contains("AUDIO") && param.contains("CODEC") && TBCDUtil.checkNotNull(value)){
    			sipcall.setAudioCodec(Integer.parseInt(value));
    		}else if(param.contains("VIDEO") && param.contains("CODEC") && TBCDUtil.checkNotNull(value)){
    			sipcall.setVideoCodec(Integer.parseInt(value));
    		}else if(param.contains("REDIRECTING") && param.contains("PARTY") && param.contains("ADDRESS")){
    			sipcall.setRedirectingPartyAddress(value);
    		}else if(param.contains("ORIGINAL") && param.contains("PARTY") && param.contains("ADDRESS")){
    			sipcall.setOriginalPartyAddress(value);
    		//v240 start
    		}else if(param.contains("PRIVACY")){
    			sipcall.setPrivacy(value);
    		//v240 end
    		}else if(param.contains("REDIRECT") && param.contains("REASON") && TBCDUtil.checkNotNull(value)){
    			sipcall.setRedirectReason(Integer.parseInt(value));
    		}else if(param.contains("RESPONSE") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setResponseCode(Integer.parseInt(value));
    		}else if(param.contains("FINISH") && param.contains("WARNING") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setFinishWarningCode(Integer.parseInt(value));
    		}else if(param.contains("FINISH") && param.contains("REASON") && param.contains("PROTOCOL") && TBCDUtil.checkNotNull(value)){
    			sipcall.setFinishReasonProtocol(Integer.parseInt(value));
    		}else if(param.contains("FINISH") && param.contains("REASON") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setFinishReasonCause(Integer.parseInt(value));
    		//v240 start
    		}else if(param.contains("CANCEL") && param.contains("REASON") && param.contains("PROTOCOL") && TBCDUtil.checkNotNull(value)){
    			sipcall.setCancelReasonProtocal(Integer.parseInt(value));
    		}else if(param.contains("CANCEL") && param.contains("REASON") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setCancelReasonCause(Integer.parseInt(value));
    		}else if(param.contains("183") && param.contains("REASON") && param.contains("PROTOCOL") && TBCDUtil.checkNotNull(value)){
    			sipcall.setReasonProtocolof183(Integer.parseInt(value));
    		}else if(param.contains("183") && param.contains("REASON") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			sipcall.setReasonCauseof183(Integer.parseInt(value));
    		}else if(param.contains("CALL") && param.contains("FAIL") && param.contains("END") && TBCDUtil.checkNotNull(value)){
    			sipcall.setCallFailEnd(Integer.parseInt(value));
    		//v240 end
    		}else if(param.contains("FIRFAILTIME") && TBCDUtil.checkNotNull(value)){
    			sipcall.setFirfailtime(Integer.parseInt(value));
    		}else if(param.contains("FIRST") && param.contains("FAIL") && param.contains("NE")){
    			sipcall.setFirstFailNeIp(value);
    		}else if(param.contains("FIRST") && param.contains("FAIL") && param.contains("TRANSACTION") && TBCDUtil.checkNotNull(value)){
    			sipcall.setFirstFailTransaction(Integer.parseInt(value));
    		}else if(param.contains("PROGRESS") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipcall.setProgressTime(Integer.parseInt(value));
    		}else if(param.contains("PRACK") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipcall.setPrackTime(Integer.parseInt(value));
    		//v240 start
    		}else if(param.contains("UPDATE") && param.contains("TIME") && param.contains("1") && TBCDUtil.checkNotNull(value)){
    			sipcall.setUpdateTime1(Integer.parseInt(value));
    		}else if(param.contains("UPDATE") && param.contains("TIME") && param.contains("2") && TBCDUtil.checkNotNull(value)){
    			sipcall.setUpdateTime2(Integer.parseInt(value));
    		}else if(param.contains("UPDATE") && param.contains("TIME") && param.contains("3") && TBCDUtil.checkNotNull(value)){
    			sipcall.setUpdateTime3(Integer.parseInt(value));
    		//v240 end
    		}else if(param.contains("ALERTING") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipcall.setAlertingTime(Integer.parseInt(value));
    		}else if(param.contains("ANSWER") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipcall.setAnswerTime(Integer.parseInt(value));
    		}else if(param.contains("RELEASE") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipcall.setReleaseTime(Integer.parseInt(value));
    		}else if(param.contains("CALL") && param.contains("DURATION") && TBCDUtil.checkNotNull(value)){
    			sipcall.setCallDuration(Integer.parseInt(value));
    		//v240 start
    		}else if(param.contains("RETRY") && param.contains("AFTER") && TBCDUtil.checkNotNull(value)){
    			sipcall.setRetryAfter(Integer.parseInt(value));
    		}else if(param.contains("RELEASE") && param.contains("PART") && TBCDUtil.checkNotNull(value)){
    			sipcall.setReleasePart(Integer.parseInt(value));
    		}else if(param.contains("USER") && param.contains("AGENT") && TBCDUtil.checkNotNull(value)){
    			sipcall.setUserAgent(value);
    		//v240 end
    		}
    	}
		sipcall.setInsertDate(format.format(new Date()));
    	return sipcall;
    }
    
	//Sv接口XDR数据结构
	public static SipSrvccEntity singleSipSrvccMsg(String[] cols,String[] fieldList) throws ParseException{
		SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
		SipSrvccEntity sipSrvcc = new SipSrvccEntity();
		for(int i=0;i<cols.length;i++){
    		String param=cols[i].toUpperCase();
    		String value=fieldList[i];
    		if(param.contains("LENGTH") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setLength(Integer.parseInt(value));
    		}else if(param.contains("LOCAL") && param.contains("PROVINCE")){
    			sipSrvcc.setLocalProvince(value);
    		}else if(param.contains("LOCAL") && param.contains("CITY")){
    			sipSrvcc.setLocalCity(value);
    		}else if(param.contains("OWNER") && param.contains("PROVINCE")){
    			sipSrvcc.setOwnerProvince(value);//OWNER_PROVINCE3
    		}else if(param.contains("OWNER") && param.contains("CITY")){
    			sipSrvcc.setOwnerCity(value);//OWNER_CITY4
    		}else if(param.contains("ROAMING") && param.contains("TYPE")){
    			sipSrvcc.setRoamingType(value);//ROAMING_TYPE5
    		}else if(param.contains("INTERFACE") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setInterFace(Integer.parseInt(value));
    		}else if(param.contains("XDR") && param.contains("ID")){
    			sipSrvcc.setXdrId(value);
    		}else if(param.contains("RAT") && !param.contains("CALL") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setRat(Integer.parseInt(value));
    		}else if(param.contains("IMSI") && !param.contains("SOURCE") && !param.contains("DEST")){
    			sipSrvcc.setImsi(value);
    		}else if(param.contains("IMEI") && !param.contains("SOURCE") && !param.contains("DEST")){
    			sipSrvcc.setImei(value);
    		}else if(param.contains("C") && param.contains("MSISDN")){
    			sipSrvcc.setCMsisdn(value);
    		}else if(param.contains("MSISDN")){
    			sipSrvcc.setMsisdn(value);
    		}else if(param.contains("PROCEDURE") && param.contains("START") && param.contains("TIME")){
    			sipSrvcc.setProcedureStartTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("END") && param.contains("TIME")){
    			sipSrvcc.setProcedureEndTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setProcedureType(Integer.parseInt(value));
    		}else if(param.contains("PROCEDURE") && param.contains("STATUS") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setProcedureStatus(Integer.parseInt(value));
    		}else if(param.contains("CALLING") && param.contains("NUMBER")){
    			sipSrvcc.setCallingNumber(value);
    		}else if(param.contains("CALLING") && param.contains("PARTY") && param.contains("URI")){
    			sipSrvcc.setCallingPartyUri(value);
    		}else if(param.contains("REQUEST") && param.contains("URI")){
    			sipSrvcc.setRequestUri(value);
    		}else if(param.contains("USER") && param.contains("IP")){
    			sipSrvcc.setUserIp(value);
    		}else if(param.contains("IC") && param.contains("ID")){
    			sipSrvcc.setIcId(value);
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("IP")){
    			sipSrvcc.setSourceNeIp(value);
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setSourceNePort(Integer.parseInt(value));
    		}else if(param.contains("DEST") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setDestNePort(Integer.parseInt(value));
    		}else if(param.contains("DEST") && param.contains("NE") && param.contains("IP")){
    			sipSrvcc.setDestNeIp(value);
    		}else if(param.contains("SOURCE") && param.contains("ACCESS")&& param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setSourceAccessType(Integer.parseInt(value));
    		}else if(param.contains("SOURCE") && param.contains("ECI")){
    			sipSrvcc.setSourceEci(value);
    		}else if(param.contains("SOURCE") && param.contains("TAC")){
    			sipSrvcc.setSourceTac(value);
    		}else if(param.contains("SOURCE") && param.contains("IMSI")){
    			sipSrvcc.setSourceImsi(value);
    		}else if(param.contains("SOURCE") && param.contains("IMEI")){
    			sipSrvcc.setSourceImei(value);
    		}else if(param.contains("DEST") && param.contains("ACCESS")&& param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setDestAccessType(Integer.parseInt(value));
    		}else if(param.contains("DEST") && param.contains("ECI")){
    			sipSrvcc.setDestEci(value);
    		}else if(param.contains("DEST") && param.contains("TAC")){
    			sipSrvcc.setDestTac(value);
    		}else if(param.contains("DEST") && param.contains("IMSI")){
    			sipSrvcc.setDestImsi(value);
    		}else if(param.contains("DEST") && param.contains("IMEI")){
    			sipSrvcc.setDestImei(value);
    		}else if(param.contains("CALLING") && param.contains("SDP") && param.contains("IP")){
    			sipSrvcc.setCallingSdpIpAddr(value);
    		}else if(param.contains("CALLING") && param.contains("AUDIO")&& param.contains("SDP") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setCallingAudioSdpPort(Integer.parseInt(value));
    		}else if(param.contains("CALLING") && param.contains("VIDEO")&& param.contains("SDP") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setCallingVideoSdpPort(Integer.parseInt(value));
    		}else if(param.contains("CALLED") && param.contains("SDP") && param.contains("IP")){
    			sipSrvcc.setCalledSdpIpAddr(value);
    		}else if(param.contains("CALLED") && param.contains("AUDIO")&& param.contains("SDP") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setCalledAudioSdpPort(Integer.parseInt(value));
    		}else if(param.contains("CALLED") && param.contains("VIDEO")&& param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setCalledVideoPort(Integer.parseInt(value));
    		}else if(param.contains("CALL") && param.contains("ID")){
    			sipSrvcc.setCallId(value);
    		}else if(param.contains("AUDIO") && param.contains("CODEC") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setAudioCodec(Integer.parseInt(value));
    		}else if(param.contains("VIDEO") && param.contains("CODEC") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setVideoCodec(Integer.parseInt(value));
    		}else if(param.contains("RESPONSE") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setResponseCode(Integer.parseInt(value));
    		}else if(param.contains("FINISH") && param.contains("WARNING") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setFinishWarningCode(Integer.parseInt(value));
    		}else if(param.contains("FINISH") && param.contains("REASON") && param.contains("PROTOCOL") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setFinishReasonProtocol(Integer.parseInt(value));
    		}else if(param.contains("FINISH") && param.contains("REASON") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setFinishReasonCause(Integer.parseInt(value));
    		
    		//v240 start
    		}else if(param.contains("CANCEL") && param.contains("REASON") && param.contains("PROTOCOL") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setCancelReasonProtocal(Integer.parseInt(value));
    		}else if(param.contains("CANCEL") && param.contains("REASON") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setCancelReasonCause(Integer.parseInt(value));
    		}else if(param.contains("183") && param.contains("REASON") && param.contains("PROTOCOL") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setReasonProtocolof183(Integer.parseInt(value));
    		}else if(param.contains("CALL") && param.contains("FAIL") && param.contains("END") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setReasonCauseof183(Integer.parseInt(value));
    		//v240 end
    			
    		}else if(param.contains("FIRFAILTIME") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setFirfailtime(Integer.parseInt(value));
    		}else if(param.contains("FIRST") && param.contains("FAIL") && param.contains("NE")){
    			sipSrvcc.setFirstFailNeIp(value);
    		}else if(param.contains("FIRST") && param.contains("FAIL") && param.contains("TRANSACTION") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setFirstFailTransaction(Integer.parseInt(value));
    		
    		//v240 start
    		}else if(param.contains("UPDATE") && param.contains("TIME") && param.contains("1") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setUpdateTime1(Integer.parseInt(value));
    		}else if(param.contains("UPDATE") && param.contains("TIME") && param.contains("2") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setUpdateTime2(Integer.parseInt(value));
    		}else if(param.contains("UPDATE") && param.contains("TIME") && param.contains("3") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setUpdateTime3(Integer.parseInt(value));
    		//v240 end
    		}else if(param.contains("ALERTING") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setAlertingTime(Integer.parseInt(value));
    		}else if(param.contains("ANSWER") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setAnswerTime(Integer.parseInt(value));
    		}else if(param.contains("RELEASE") && param.contains("TIME") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setReleaseTime(Integer.parseInt(value));
    		}else if(param.contains("CALL") && param.contains("DURATION") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setCallDuration(Integer.parseInt(value));
    		}else if(param.contains("ATU") && param.contains("STI")){
    			sipSrvcc.setAtuSti(value);
    		}else if(param.contains("SSI")){
    			sipSrvcc.setSsi(value);
    		//v240 start
    		}else if (param.contains("RETRY") && param.contains("AFTER") && TBCDUtil.checkNotNull(value)){
    			sipSrvcc.setRetryAfter(Integer.parseInt(value));
    		}
    		//v240 end
    	}
		sipSrvcc.setInsertDate(format.format(new Date()));
		
		return sipSrvcc;
	}
	
	//Sv接口XDR数据结构
	public static SrvccEntity singleSrvcc(String[] cols,String[] fieldList) throws ParseException{
		SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
    	SrvccEntity srvcc = new SrvccEntity();
    	for(int i=0;i<cols.length;i++){
    		String param=cols[i].toUpperCase();
    		String value=fieldList[i];
    		if(param.contains("LENGTH") && TBCDUtil.checkNotNull(value)){
    			srvcc.setLength(Integer.parseInt(value));
    		}else if(param.contains("LOCAL") && param.contains("PROVINCE")){
    			srvcc.setLocalProvince(value);
    		}else if(param.contains("LOCAL") && param.contains("CITY")){
    			srvcc.setLocalCity(value);
    		}else if(param.contains("OWNER") && param.contains("PROVINCE")){
    			srvcc.setOwnerProvince(value);//OWNER_PROVINCE3
    		}else if(param.contains("OWNER") && param.contains("CITY")){
    			srvcc.setOwnerCity(value);//OWNER_CITY4
    		}else if(param.contains("ROAMING") && param.contains("TYPE")){
    			srvcc.setRoamingType(value);//ROAMING_TYPE5
    		}else if(param.contains("INTERFACE") && TBCDUtil.checkNotNull(value)){
    			srvcc.setInterFace(Integer.parseInt(value));
    		}else if(param.contains("XDR") && param.contains("ID")){
    			srvcc.setXdrId(value);
    		}else if(param.contains("RAT") && TBCDUtil.checkNotNull(value)){
    			srvcc.setRat(Integer.parseInt(value));
    		}else if(param.contains("IMSI")){
    			srvcc.setImsi(value);
    		}else if(param.contains("IMEI")){
    			srvcc.setImei(value);
    		}else if(param.contains("MSISDN")){
    			srvcc.setMsisdn(value);
    		}else if(param.contains("PROCEDURE") && param.contains("START") && param.contains("TIME")){
    			srvcc.setProcedureStartTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("END") && param.contains("TIME")){
    			srvcc.setProcedureEndTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			srvcc.setProcedureType(Integer.parseInt(value));
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("IP")){
    			srvcc.setSourceNeIp(value);
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			srvcc.setSourceNePort(Integer.parseInt(value));
    		}else if(param.contains("DEST") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			srvcc.setDestNePort(Integer.parseInt(value));
    		}else if(param.contains("DEST") && param.contains("NE") && param.contains("IP")){
    			srvcc.setDestNeIp(value);
    		}else if(param.contains("ROAM") && param.contains("DIRECTION") && TBCDUtil.checkNotNull(value)){
    			srvcc.setRoamDirection(Integer.parseInt(value));
    		}else if(param.contains("HOME") && param.contains("MCC") && TBCDUtil.checkNotNull(value)){
    			srvcc.setHomeMcc(Integer.parseInt(value));
    		}else if(param.contains("HOME") && param.contains("MNC") && TBCDUtil.checkNotNull(value)){
    			srvcc.setHomeMnc(Integer.parseInt(value));
    		}else if(param.contains("MCC") && TBCDUtil.checkNotNull(value)){
    			srvcc.setMcc(Integer.parseInt(value));
    		}else if(param.contains("MNC") && TBCDUtil.checkNotNull(value)){
    			srvcc.setMnc(Integer.parseInt(value));
    		}else if(param.contains("TARGET") && param.contains("LAC") && TBCDUtil.checkNotNull(value)){
    			srvcc.setTargetLac(Integer.parseInt(value));
    		}else if(param.contains("SOURCE") && param.contains("TAC")){
    			srvcc.setSourceTac(value);
    		}else if(param.contains("SOURCE") && param.contains("ECI")){
    			srvcc.setSourceEci(value);
    		}else if(param.contains("SV") && param.contains("FLAGS") && TBCDUtil.checkNotNull(value)){
    			srvcc.setSvFlags(Integer.parseInt(value));
    		}else if(param.contains("UL") && param.contains("MSC") && param.contains("IP")){
    			srvcc.setUlCMscIp(value);
    		}else if(param.contains("DL") && param.contains("MME") && param.contains("IP")){
    			srvcc.setDlCMmeIp(value);
    		}else if(param.contains("UL") && param.contains("MSC") && param.contains("TEID")){
    			srvcc.setUlCMscTeid(value);
    		}else if(param.contains("DL") && param.contains("MME") && param.contains("TEID")){
    			srvcc.setDlCMmeTeid(value);
    		}else if(param.contains("STN") && param.contains("SR")){
    			srvcc.setStnSr(value);
    		}else if(param.contains("TARGET") && param.contains("RNC")){
    			srvcc.setTargetRncId(value);
    		}else if(param.contains("TARGET") && param.contains("CELL")){
    			srvcc.setTargetCellId(value);
    		}else if(param.contains("ARP") && TBCDUtil.checkNotNull(value)){
    			srvcc.setArp(Integer.parseInt(value));
    		}else if(param.contains("REQUEST") && param.contains("RESULT") && TBCDUtil.checkNotNull(value)){
    			srvcc.setRequestResult(Integer.parseInt(value));
    		}else if(param.contains("RESULT") && TBCDUtil.checkNotNull(value)){
    			srvcc.setResult(Integer.parseInt(value));
    		}else if(param.contains("SV") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			srvcc.setSvCause(Integer.parseInt(value));
    		}else if(param.contains("POST") && param.contains("FAILURE")&& param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			srvcc.setPostFailureCause(Integer.parseInt(value));
    		}else if(param.contains("RESP") && param.contains("DELAY") && TBCDUtil.checkNotNull(value)){
    			srvcc.setRespDelay(Integer.parseInt(value));
    		}else if(param.contains("SV") && param.contains("DELAY") && TBCDUtil.checkNotNull(value)){
    			srvcc.setSvDelay(Integer.parseInt(value));
    		}
    	}
		srvcc.setInsertDate(format.format(new Date()));
    	return srvcc;
    }
	
	public static AuthenEntity singleSigAuthen(String[] cols,String[] fieldList) throws ParseException{
		SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
    	AuthenEntity authen = new AuthenEntity();
    	for(int i=0;i<cols.length;i++){
    		String param=cols[i].toUpperCase();
    		String value=fieldList[i];
    		if(param.contains("LENGTH") && TBCDUtil.checkNotNull(value)){
    			authen.setLength(Integer.parseInt(value));
    		}else if(param.contains("LOCAL") && param.contains("PROVINCE")){
    			authen.setLocalProvince(value);
    		}else if(param.contains("LOCAL") && param.contains("CITY")){
    			authen.setLocalCity(value);
    		}else if(param.contains("OWNER") && param.contains("PROVINCE")){
    			authen.setOwnerProvince(value);//OWNER_PROVINCE3
    		}else if(param.contains("OWNER") && param.contains("CITY")){
    			authen.setOwnerCity(value);//OWNER_CITY4
    		}else if(param.contains("ROAMING") && param.contains("TYPE")){
    			authen.setRoamingType(value);//ROAMING_TYPE5
    		}else if(param.contains("INTERFACE") && TBCDUtil.checkNotNull(value)){
    			authen.setInterFace(Integer.parseInt(value));
    		}else if(param.contains("XDR") && param.contains("ID")){
    			authen.setXdrId(value);
    		}else if(param.contains("RAT") && TBCDUtil.checkNotNull(value)){
    			authen.setRat(Integer.parseInt(value));
    		}else if(param.contains("IMSI")){
    			authen.setImsi(value);
    		}else if(param.contains("IMEI")){
    			authen.setImei(value);
    		}else if(param.contains("MSISDN")){
    			authen.setMsisdn(value);
    		}else if(param.contains("PROCEDURE") && param.contains("START") && param.contains("TIME")){
    			authen.setProcedureStartTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("END") && param.contains("TIME")){
    			authen.setProcedureEndTime(format.parse(value));
    		}else if(param.contains("TRANSACTION") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			authen.setTransactionType(Integer.parseInt(value));
    		}else if(param.contains("TRANSACTION") && param.contains("STATUS") && TBCDUtil.checkNotNull(value)){
    			authen.setTransactionStatus(Integer.parseInt(value));
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("IP")){
    			authen.setSourceNeIp(value);
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			authen.setSourceNePort(Integer.parseInt(value));
    		}else if(param.contains("DESTINATION") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			authen.setDestinationNePort(Integer.parseInt(value));
    		}else if(param.contains("DESTINATION") && param.contains("NE") && param.contains("IP")){
    			authen.setDestinationNeIp(value);
    		}else if(param.contains("EXPERIMENTAL") && param.contains("RESULT") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			authen.setExperimentalResultCode(Integer.parseInt(value));
    		}else if(param.contains("RESULT") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			authen.setResultCode(Integer.parseInt(value));
    		}else if(param.contains("ORIGIN") && param.contains("REALM")){
    			authen.setOriginRealm(value);
    		}else if(param.contains("DESTINATION") && param.contains("REALM")){
    			authen.setDestinationRealm(value);
    		}else if(param.contains("ORIGIN") && param.contains("HOST")){
    			authen.setOriginHost(value);
    		}else if(param.contains("DESTINATION") && param.contains("HOST")){
    			authen.setDestinationHost(value);
    		//v240 start
    		}else if(param.contains("DATA") && param.contains("REFERENCE")){
    			authen.setDataReference(value);//datarefrence要不要改成int型？
    		}else if(param.contains("TADS") && param.contains("RESULT") && TBCDUtil.checkNotNull(value)){
    			authen.setTadsResult(Integer.parseInt(value));
    		}else if(param.contains("SESSION") && param.contains("ID")){
    			authen.setSessionId(value);
    		}else if(param.contains("USER") && param.contains("ECI") && TBCDUtil.checkNotNull(value)){
    			authen.setUserEci(Integer.parseInt(value));
    		}else if(param.contains("USER") && param.contains("TAC") && TBCDUtil.checkNotNull(value)){
    			authen.setUserTac(Integer.parseInt(value));
    		}
    		//v240 end
    	}
		authen.setInsertDate(format.format(new Date()));
		return authen;
    }
	
    public static PccEntity singleSigPccMsg(String[] cols,String[] fieldList) throws ParseException{
    	SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
    	PccEntity pcc = new PccEntity();
    	for(int i=0;i<cols.length;i++){
    		String param=cols[i].toUpperCase();
    		String value=fieldList[i];
    		if(param.contains("LENGTH") && TBCDUtil.checkNotNull(value)){
    			pcc.setLength(Integer.parseInt(value));
    		}else if(param.contains("LOCAL") && param.contains("PROVINCE")){
    			pcc.setLocalProvince(value);
    		}else if(param.contains("LOCAL") && param.contains("CITY")){
    			pcc.setLocalCity(value);
    		}else if(param.contains("OWNER") && param.contains("PROVINCE")){
    			pcc.setOwnerProvince(value);//OWNER_PROVINCE3
    		}else if(param.contains("OWNER") && param.contains("CITY")){
    			pcc.setOwnerCity(value);//OWNER_CITY4
    		}else if(param.contains("ROAMING") && param.contains("TYPE")){
    			pcc.setRoamingType(value);//ROAMING_TYPE5
    		}else if(param.contains("INTERFACE") && TBCDUtil.checkNotNull(value)){
    			pcc.setInterFace(Integer.parseInt(value));
    		}else if(param.contains("XDR") && param.contains("ID")){
    			pcc.setXdrId(value);
    		}else if(param.contains("RAT") && !param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			pcc.setRat(Integer.parseInt(value));
    		}else if(param.contains("IMSI")){
    			pcc.setImsi(value);
    		}else if(param.contains("IMEI")){
    			pcc.setImei(value);
    		}else if(param.contains("MSISDN")){
    			pcc.setMsisdn(value);
    		}else if(param.contains("PROCEDURE") && param.contains("START") && param.contains("TIME")){
    			pcc.setProcedureStartTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("END") && param.contains("TIME")){
    			pcc.setProcedureEndTime(format.parse(value));
    		}else if(param.contains("PROCEDURE") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			pcc.setProcedureType(Integer.parseInt(value));
    		}else if(param.contains("IC") && param.contains("ID")){
    			pcc.setIcid(value);
    		//v240 start
    		}else if(param.contains("TRANSACTION") && param.contains("STATUS") && TBCDUtil.checkNotNull(value)){
    			pcc.setTransactionStatus(Integer.parseInt(value));
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("IP")){
    			pcc.setSourceNeIp(value);
    		}else if(param.contains("SOURCE") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			pcc.setSourceNePort(Integer.parseInt(value));
    		}else if(param.contains("DESTINATION") && param.contains("NE") && param.contains("IP")){
    			pcc.setDestinationNeIp(value);
    		}else if(param.contains("DESTINATION") && param.contains("NE") && param.contains("PORT") && TBCDUtil.checkNotNull(value)){
    			pcc.setDestinationNePort(Integer.parseInt(value));	
    		//v240 end	
    			
    		}else if(param.contains("ORIGIN") && param.contains("REALM")){
    			pcc.setOriginRealm(value);
    		}else if(param.contains("DESTINATION") && param.contains("REALM")){
    			pcc.setDestinationRealm(value);
    		}else if(param.contains("ORIGIN") && param.contains("HOST")){
    			pcc.setOriginHost(value);
    		}else if(param.contains("DESTINATION") && param.contains("HOST")){
    			pcc.setDestinationHost(value);
    		}else if(param.contains("SGSN") && param.contains("SGW")){
    			pcc.setSgsnSgwSigIP(value);
    		}else if(param.contains("AF") && param.contains("APP")){
    			pcc.setAfAppID(value);
    		}else if(param.contains("CC") && param.contains("REQUEST")  && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			pcc.setCcRequestType(Integer.parseInt(value));
    		}else if(param.contains("RX") && param.contains("REQUEST")  && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			pcc.setRxRequestType(Integer.parseInt(value));
    		}else if(param.contains("MEDIA") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			pcc.setMediaType(Integer.parseInt(value));
    		}else if(param.contains("ABORT") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			pcc.setAbortCause(Integer.parseInt(value));
    		}else if(param.contains("EXPERIMENTAL") && param.contains("RESULT") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			pcc.setExperimentalResultCode(Integer.parseInt(value));
    		}else if(param.contains("RESULT") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			pcc.setResultCode(Integer.parseInt(value));
    		}else if(param.contains("SESSION") && param.contains("RELEASE") && param.contains("CAUSE") && TBCDUtil.checkNotNull(value)){
    			pcc.setSessionReleaseCause(Integer.parseInt(value));
    		}else if(param.contains("RULE") && param.contains("FAILURE") && param.contains("CODE") && TBCDUtil.checkNotNull(value)){
    			pcc.setRuleFailureCode(Integer.parseInt(value));
    		}else if(param.contains("SESSION") && param.contains("ID")){
    			log.info("*******match session id***********************");
    			pcc.setSessionId(value);
    		}else if(param.contains("IPV6") && param.contains("PREFIX")){
    			pcc.setIpv6Prefix(value);
    		}else if(param.contains("CALLED") && param.contains("STATION") && param.contains("ID") && TBCDUtil.checkNotNull(value)){
    			pcc.setCalledStationId(Integer.parseInt(value));
    		//v240 start
    		}else if(param.contains("RAT") && param.contains("TYPE") && TBCDUtil.checkNotNull(value)){
    			pcc.setRatType(Integer.parseInt(value));
    		}else if(param.contains("SERVICE") && param.contains("INFO") && param.contains("STATUS") && TBCDUtil.checkNotNull(value)){
    			pcc.setServiceInfoStatus(Integer.parseInt(value));
    		}else if(param.contains("USER") && param.contains("ECI") && TBCDUtil.checkNotNull(value)){
    			pcc.setUserEci(Integer.parseInt(value));
    		}else if(param.contains("USER") && param.contains("TAC") && TBCDUtil.checkNotNull(value)){
    			pcc.setUserTac(Integer.parseInt(value));
    		}else if(param.contains("QCI") && TBCDUtil.checkNotNull(value)){
    			pcc.setQci(Integer.parseInt(value));
    		}//v240 end
    	}
    	pcc.setInsertDate(format.format(new Date()));
    	return pcc;
    }
    
    public static BiccEntity singleSigBiccMsg(String[] fieldList) throws ParseException{
    	SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
    	BiccEntity nc = new BiccEntity();
    	nc.setLength(Integer.parseInt(fieldList[0]));
    	nc.setLocalProvince(fieldList[1]);
    	nc.setLocalCity(fieldList[2]);
    	nc.setOwnerProvince(fieldList[3]);//OWNER_PROVINCE3
    	nc.setOwnerCity(fieldList[4]);//OWNER_CITY4
    	nc.setRoamingType(fieldList[5]);//ROAMING_TYPE5
    	nc.setInterFace(Integer.parseInt(fieldList[6]));
    	nc.setXdrId(fieldList[7]);
    	nc.setRat(Integer.parseInt(fieldList[8]));
    	nc.setImsi(fieldList[9]);
    	nc.setImei(fieldList[10]);
    	nc.setMsisdn(fieldList[11]);
    	
    	nc.setbTime(format.parse(fieldList[12]));//寮�鏃堕棿
    	nc.seteTime(format.parse(fieldList[13]));//缁撴潫鏃堕棿
    	if(TBCDUtil.checkNotNull(fieldList[14]))
    		nc.setProtocolId(Integer.parseInt(fieldList[14]));     //鍗忚
    	if(TBCDUtil.checkNotNull(fieldList[15]))                       
    		nc.setSpckind(Integer.parseInt(fieldList[15]));        //缂栫爜绫诲埆
    	if(TBCDUtil.checkNotNull(fieldList[16]))                       
    		nc.setOpc(Integer.parseInt(fieldList[16]));            //婧愪俊浠ょ偣
    	if(TBCDUtil.checkNotNull(fieldList[17]))                       
    		nc.setDpc(Integer.parseInt(fieldList[17]));            //鐩殑淇′护鐐�
    	if(TBCDUtil.checkNotNull(fieldList[18]))                       
    		nc.setPcm(Integer.parseInt(fieldList[18]));            //pcm绾�
    	if(TBCDUtil.checkNotNull(fieldList[19]))                       
    		nc.setCic(Integer.parseInt(fieldList[19]));            //鏃堕殭鍙�
    	if(TBCDUtil.checkNotNull(fieldList[20]))                       
    		nc.setSls(Integer.parseInt(fieldList[20]));            //淇′护閾捐矾閫夋嫨鐮�
    	nc.setCallingNum(fieldList[21]); //涓诲彨鍙风爜
    	nc.setCalledNum(fieldList[22]);  //琚彨鍙风爜
    	nc.setoCalledNum(fieldList[23]); //鍘熻鍙彿鐮�
    	nc.setRecalledNum(fieldList[24]);//鏀瑰彂鍙风爜
    	nc.setMsrn(fieldList[25]);       //婕父鍙风爜
    	if(TBCDUtil.checkNotNull(fieldList[26]))
    		nc.setCallingNumNature(Integer.parseInt(fieldList[26])); //涓诲彨鍙风爜灞炴�聽
    	if(TBCDUtil.checkNotNull(fieldList[27]))                         
    		nc.setCalledNumNature(Integer.parseInt(fieldList[27]));  //琚彨鍙风爜灞炴�
    	if(TBCDUtil.checkNotNull(fieldList[28]))                         
    		nc.setOcalledNumNature(Integer.parseInt(fieldList[28])); //鍘熻鍙彿鐮佸睘鎬�
    	if(TBCDUtil.checkNotNull(fieldList[29]))                         
    		nc.setRecalledNumNature(Integer.parseInt(fieldList[29]));//鏀瑰彂鍙风爜灞炴�
    	if(TBCDUtil.checkNotNull(fieldList[30]))                         
    		nc.setCalledStatus(Integer.parseInt(fieldList[30]));     //琚彨鐘舵�
    	if(TBCDUtil.checkNotNull(fieldList[31]))                         
    		nc.setCallTrans(Integer.parseInt(fieldList[31]));        //鍛煎彨杞Щ
    	if(TBCDUtil.checkNotNull(fieldList[32]))                         
    		nc.setCallTransType(Integer.parseInt(fieldList[32]));    //鍛艰浆绫诲瀷
    	if(TBCDUtil.checkNotNull(fieldList[33]))                         
    		nc.setChargeind(Integer.parseInt(fieldList[33]));        //璁¤垂鎸囩ず
    	if(TBCDUtil.checkNotNull(fieldList[34]))                         
    		nc.setEventId(Integer.parseInt(fieldList[34]));          //浜嬩欢绫诲瀷
    	if(TBCDUtil.checkNotNull(fieldList[35]))                         
    		nc.setEventCause(Integer.parseInt(fieldList[35]));       //閲婃斁鍘熷洜
    	if(TBCDUtil.checkNotNull(fieldList[36]))                         
    		nc.setEventResult(Integer.parseInt(fieldList[36]));      //浜嬩欢缁撴灉
    	if(TBCDUtil.checkNotNull(fieldList[37]))                         
    		nc.setSeizureDur(Integer.parseInt(fieldList[37]));       //鍗犵敤鏃堕暱
    	if(TBCDUtil.checkNotNull(fieldList[38]))                         
    		nc.setAnswerDur(Integer.parseInt(fieldList[38]));        //閫氳瘽鏃堕暱
    	if(TBCDUtil.checkNotNull(fieldList[39]))                         
    		nc.setAcmOffset(Integer.parseInt(fieldList[39]));        //鍦板潃鍏ㄦ椂闂�
    	if(TBCDUtil.checkNotNull(fieldList[40]))                         
    		nc.setAnmOffset(Integer.parseInt(fieldList[40]));        //搴旂瓟鏃堕棿
    	if(TBCDUtil.checkNotNull(fieldList[41]))                         
    		nc.setRelOffset(Integer.parseInt(fieldList[41]));        //閲婃斁鏃堕棿
    	if(TBCDUtil.checkNotNull(fieldList[42]))                         
    		nc.setRlcOffset(Integer.parseInt(fieldList[42]));        //閲婃斁瀹屾垚鏃堕棿
    	if(TBCDUtil.checkNotNull(fieldList[43]))                         
    		nc.setSaoOffset(Integer.parseInt(fieldList[43]));        //鏈�悗涓�潯鍓嶅悜娑堟伅鏃堕棿
    	if(TBCDUtil.checkNotNull(fieldList[44]))                         
    		nc.setAnsOffset(Integer.parseInt(fieldList[44]));        //绗竴鏉″悗鍚戞秷鎭椂闂�
    	if(TBCDUtil.checkNotNull(fieldList[45]))                         
    		nc.setProcess1(Integer.parseInt(fieldList[45]));         //娑堟伅鍑虹幇1
    	if(TBCDUtil.checkNotNull(fieldList[46]))                         
    		nc.setProcess2(Integer.parseInt(fieldList[46]));         //娑堟伅鍑虹幇2
    	if(TBCDUtil.checkNotNull(fieldList[47]))                         
    		nc.setProcess3(Integer.parseInt(fieldList[47]));         //娑堟伅鍑虹幇3
    	if(TBCDUtil.checkNotNull(fieldList[48]))                         
    		nc.setDirection1(Integer.parseInt(fieldList[48]));       //娑堟伅鏂瑰悜1
    	if(TBCDUtil.checkNotNull(fieldList[49]))                         
    		nc.setDirection2(Integer.parseInt(fieldList[49]));       //娑堟伅鏂瑰悜2
    	if(TBCDUtil.checkNotNull(fieldList[50]))                         
    		nc.setDirection3(Integer.parseInt(fieldList[50]));       //娑堟伅鏂瑰悜3
    	if(TBCDUtil.checkNotNull(fieldList[51]))                         
    		nc.setXdrType(Integer.parseInt(fieldList[51]));          //XDR绫诲瀷
    	if(TBCDUtil.checkNotNull(fieldList[52]))                         
    		nc.setBearType(Integer.parseInt(fieldList[52]));         //鎵胯浇绫诲瀷
    	if(TBCDUtil.checkNotNull(fieldList[53]))                         
    		nc.setoAddresss(Long.parseLong(fieldList[53]));          //鎵胯浇鍦板潃锛堝彂璧凤級
    	if(TBCDUtil.checkNotNull(fieldList[54]))                         
    		nc.setdAddresss(Long.parseLong(fieldList[54]));          //鎵胯浇鍦板潃锛堢粨鏉燂級
    	if(TBCDUtil.checkNotNull(fieldList[55]))                         
    		nc.setCdrId(Long.parseLong(fieldList[55]));              //cdrid
    	if(TBCDUtil.checkNotNull(fieldList[56]))                         
    		nc.setSessionId(Long.parseLong(fieldList[56]));          //sessionid
    	if(TBCDUtil.checkNotNull(fieldList[57]))                         
    		nc.setGlobalId(Long.parseLong(fieldList[57]));           //globalid
    	
    	nc.setInsertDate(format.format(new Date()));
    	return nc;
    }
}
